<template>
  <div id="app">
    <router-view v-if="isRouterAlive" ref="appView" />
  </div>
</template>

<script>
export default {
  name: 'App',
  provide() {
    return {
      // 主动刷新页面
      reload: this.reload,

      // 主动关闭标签页
      closeTag: this.closeTag
    }
  },
  data() {
    return {
      isRouterAlive: true
    }
  },
  methods: {
    reload() {
      this.isRouterAlive = false
      this.$nextTick(function() {
        this.isRouterAlive = true
      })
    },
    closeTag() {
      const _this = this.$refs.appView
      _this.closeTag()
    }
  }
}
</script>
